home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / CW GUSI 1.6.4 / Examples / GUSITest_P.h < prev    next >
Text File  |  1995-01-19  |  960b  |  35 lines

  1. /*********************************************************************
  2. File        :    GUSI                -    Grand Unified Socket Interface
  3. File        :    GUSITest_P.h    -    Common testing gear
  4. Author    :    Matthias Neeracher <neeri@iis.ethz.ch>
  5. Language    :    MPW C
  6.  
  7. $Log: GUSITest_P.h,v $
  8. Revision 1.1  1994/02/25  02:48:27  neeri
  9. Initial revision
  10.  
  11. *********************************************************************/
  12.  
  13. #ifndef _GUSITEST_P_
  14. #define _GUSITEST_P_
  15.  
  16. #include <CType.h>
  17.  
  18. #define NROFCHARS                26
  19. #define DECODE(ch)            ((ch) ? (ch) - (isupper(ch) ? 'A' : 'a') + 1 : 0)
  20. #define CMDCODE(ch1,ch2)    (DECODE(ch1)*(NROFCHARS+1)+DECODE(ch2))
  21. #define NROFCMDS                (NROFCHARS+1)*(NROFCHARS+1)
  22.  
  23. typedef struct {
  24.     TestCmd            proc;
  25.     const char *    syntax;
  26.     const char *    help;
  27. } CmdDef;
  28.  
  29. extern CmdDef commands[NROFCMDS];
  30.  
  31. #define DISPATCH(ch1,ch2)    commands[CMDCODE(ch1,ch2)].proc
  32. #define USAGE(ch1,ch2)         commands[CMDCODE(ch1,ch2)].syntax
  33. #define HELPMSG(ch1,ch2)     commands[CMDCODE(ch1,ch2)].help
  34.  
  35. #endif